<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <img src="./头像.png" alt="">
    <img src="./头像.png" alt="">
    <img src="./头像.png" alt="">
    <img src="./头像.png" alt="">
    <img src="./头像.png" alt="">
</body>
<script>
    // let和const存在块级作用域，而var不存在
    const imgArr = document.querySelectorAll('img')
    for(var i = 0; i < 5; i++) {
        imgArr[i].onmouseover = function() {
            var text = document.createTextNode(i)
            this.appendChild(text)
            this.style.height = (i + 1) * 100 + 'px'
        }
        imgArr[i].onmouseleave = function() {
            this.style.height = '100px'
        }
    }
</script>
<style>
    img {
        width: 100px;
    }
</style>
</html>